<?php

use kartik\alert\Alert;
use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\EduAppearSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '门店提现';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="edu-appear-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('Create Edu Appear', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?php
    if (Yii::$app->session->get('yes')) {

        echo Alert::widget([
            'type' => Alert::TYPE_DANGER,
            'title' => '消息提示:',
            'titleOptions' => ['icon' => 'info-sign'],
            'body' => Yii::$app->session->get('message') ]);
    }
    ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

//            'id',
//            'openid',
            [
                'label' => '门店',
                'attribute' => 'dot.room_name',
            ],
            'amount',
//            'status',
            [
                'attribute' => 'status',
                'enableSorting' => false,
                'value' => 'statusValue',
                'filter' => \backend\models\EduAppear::attributeValue()['status']
            ],
//            'reason',
            'create_time:datetime',
            //'finish_time:datetime',
            //'check_id',

            ['class' => 'yii\grid\ActionColumn',
                'header' => '操作',
                'template' => '{view} {update} {amount}',
                'buttons' => [
                    'amount' => function ($url, $model, $key) {
                        if ($model->status == 1) {
                            return Html::a('<span class="glyphicon glyphicon-btc"></span>', ['amount', 'id' => $model->id], [
                                'title' => Yii::t('yii', '提现'),
                                'aria-label' => Yii::t('yii', '提现'),
                                'data-pjax' => '0',
                                'data-method' => 'post',
                                'data-confirm' => '确定提现?',
                                'class' => 'click-on',
                            ]);
                        } else {
                            return '';
                        }
                    }
                ],
            ],
        ],
    ]); ?>
</div>
<?php
$script = <<< JS
    $(".pagination").append('&nbsp;跳转<input id="invalue" type="text" style="border-radius: 5px;outline: none;border: solid 1px #dddddd;width: 52px;height: 34px;text-align: center;" class="pane"/>页&nbsp;<button id="skip" class="btn btn-default skip ok"">确定</button>');
    
    $('#skip').click(function() {
        var page = $('#invalue').val();
        location.href = "index.php?r=edu-appear/index&page="+ page;
    });
    // $(".click-on").click(function(event) {
    //     $(this).parent().find('.click-on').attr('href','') ;
    // });
JS;
$this->registerJs($script);
?>
